package priv.tuyou.system.serviceImpl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import priv.tuyou.dao.IDao;
import priv.tuyou.exception.ServiceException;
import priv.tuyou.system.dao.IArticleDao;
import priv.tuyou.system.po.Article;
import priv.tuyou.system.service.IArticleService;

@Service
public class ArticleServiceImpl implements IArticleService{

	@Resource
	protected IDao dao;
	@Resource
	protected IArticleDao articleDao;
	
	@Override
	public Article add(String title, String outline, String cover, String content) throws ServiceException {
		
		Article article = new Article();
		article.setTitle(title);
		article.setOutline(outline);
		article.setCover(cover);
		article.setContent(content);
		dao.save(article);
		return article;
	}
	
	@Override
	public Article update(long id, String title, String outline, String cover, String content) throws ServiceException {
		
		Article article = dao.get(Article.class, id);
		article.setTitle(title);
		article.setOutline(outline);
		article.setCover(cover);
		article.setContent(content);
		dao.update(article);
		return article;
	}
}
